package com.tvunetworks.center.user.controller;

import com.tvunetworks.center.common.model.LoginUser;
import com.tvunetworks.center.common.util.Result;
import com.tvunetworks.center.common.util.ResultUtil;
import com.tvunetworks.center.user.annotation.Logined;
import com.tvunetworks.center.user.model.param.SetUserDeviceGroupParam;
import com.tvunetworks.center.user.service.CustomizedUserDeviceGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @program: tvucc-aggregator
 * @description: CustomizedUserDeviceGroupController
 * @author lebronchen
 * @create: 2020-03-13 10:11
 **/
@RestController
@RequestMapping("/userDeviceGroup")
public class CustomizedUserDeviceGroupController {

    @Autowired
    private CustomizedUserDeviceGroupService userDeviceGroupService;

    /**
     *
     * @param loginUser loginUser
     * @param param param
     * @return Result
     */
    @PostMapping("/setUserDeviceGroup")
    public Result setUserDeviceGroup(@Logined LoginUser loginUser, @RequestBody @Valid SetUserDeviceGroupParam param){
        param.setUserId(loginUser.getId());
        userDeviceGroupService.setUserDeviceGroup(param);
        return ResultUtil.success();
    }
}
